﻿using System;

namespace PD.Web.DynamicData.FieldTemplates
{
    /// <summary>
    /// Represents the unit field template control.
    /// </summary>
    public partial class Unit : System.Web.DynamicData.FieldTemplateUserControl
    {
        /// <summary>
        /// Gets the data control that handles the data field in a field template.
        /// </summary>
        /// <returns>A data control that handles the data field in a field template.</returns>
        public override System.Web.UI.Control DataControl
        {
            get
            {
                return this.Literal1;
            }
        }

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            double progress;
            if (!this.Page.IsPostBack && double.TryParse(this.Literal1.Text, out progress))
            {
                this.progress.Style[System.Web.UI.HtmlTextWriterStyle.Width] = ((int)progress).ToString() + "px";
            }
        }
    }
}